﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Logic.Interface;
using Meqs.Entity;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Reports 的摘要说明
/// </summary>
public class Reports
{
    /// <summary>
    /// 获取各年级考试的报表种类
    /// </summary>
    /// <param name="examType">1 统考，0 校考</param>
    /// <param name="grade"></param>
    /// <returns></returns>
    public static string[] GetExamTypes(int examType, int grade)
    {
        string[] keyWords = null;
        if (examType == 1)
        {
            IReporTtypeEducationLogic il = Container<IReporTtypeEducationLogic>.Instance;
            Hashtable ht = new Hashtable();
            ht.Add("UseGrade", grade);
            IList<ReporTtypeEducation> rtes = il.FindAll(ht);
            keyWords = new string[rtes.Count];
            for (int i = 0; i < rtes.Count; i++)
            {
                keyWords[i] = rtes[i].Keyword;
            }
        }
        else
        {
            IReportTypeSchoolLogic il = Container<IReportTypeSchoolLogic>.Instance;
            Hashtable ht = new Hashtable();
            ht.Add("UseGrade", grade);
            ht.Add("SchoolMark", CommonScore.GetSchoolMark);
            IList<ReportTypeSchool> rtes = il.FindAll(ht);
            keyWords = new string[rtes.Count];
            for (int i = 0; i < rtes.Count; i++)
            {
                keyWords[i] = rtes[i].Keyword;
            }
        }
        return keyWords;
    }

    /// <summary>
    /// 获取各年级考试的报表种类
    /// </summary>
    /// <param name="examType">1 统考，0 校考</param>
    /// <param name="grade"></param>
    /// <returns></returns>
    public static string[] GetExamName(int examType, int grade)
    {
        string[] keyWords = null;
        if (examType == 1)
        {
            IReporTtypeEducationLogic il = Container<IReporTtypeEducationLogic>.Instance;
            Hashtable ht = new Hashtable();
            ht.Add("UseGrade", grade);
            IList<ReporTtypeEducation> rtes = il.FindAll(ht);
            keyWords = new string[rtes.Count];
            for (int i = 0; i < rtes.Count; i++)
            {
                keyWords[i] = rtes[i].ReportName;
            }
        }
        else
        {
            IReportTypeSchoolLogic il = Container<IReportTypeSchoolLogic>.Instance;
            Hashtable ht = new Hashtable();
            ht.Add("UseGrade", grade);
            ht.Add("SchoolMark", CommonScore.GetSchoolMark);
            IList<ReportTypeSchool> rtes = il.FindAll(ht);
            keyWords = new string[rtes.Count];
            for (int i = 0; i < rtes.Count; i++)
            {
                keyWords[i] = rtes[i].ReportName;
            }
        }
        return keyWords;
    }

    /// <summary>
    /// 查询参数生成接口
    /// </summary>
    /// <param name="examType">1 统考，0 校考</param>
    /// <param name="keyWord">报表关键字</param>
    /// <returns></returns>
    public static Meqs.Logic.Interface.IExamSettings QueryExamSetting(int examType, string keyWord)
    {
        if (examType == 1)
        {
            switch (keyWord)
            {
                case Reports.TYPE_KINDSET:
                    return Container<IKindSettingsEducationLogic>.Instance;
                case Reports.TYPE_SECTIONSET:
                    return Container<ISectionSettingsEducationLogic>.Instance;
                case Reports.TYPE_DISTRIBUTIONSET:
                    return Container<IDistributionSettingsEducationLogic>.Instance;
                case Reports.TYPE_SCOREPOINTSET:
                    return Container<IScorePointEducationLogic>.Instance; 
            }
        }
        else
        {
            switch (keyWord)
            {
                case Reports.TYPE_KINDSET:
                    return Container<IKindSettingsSchoolLogic>.Instance;
                case Reports.TYPE_SECTIONSET:
                    return Container<ISectionSettingsSchoolLogic>.Instance;
                case Reports.TYPE_DISTRIBUTIONSET:
                    return Container<IDistributionSettingsSchoolLogic>.Instance;

            }
        }
        //throw new Exception("不支持的参数接口");
        return null;
    }

    /// <summary>
    /// 报表缓存接口
    /// </summary>
    /// <param name="examType">1 统考，0 校考</param>
    /// <param name="keyWord">报表关键字</param>
    /// <returns></returns>
    public static Meqs.Logic.Interface.IExamCatch QueryExamCatch(int examType, string keyWord)
    {
        if (examType == 1)
        {
            switch (keyWord)
            {
                case Reports.CATCH_KINDSET_GRADE:
                    return Container<IGradeKindEducationLogic>.Instance;
                case Reports.CATCH_KINDSET_CLASS:
                    return Container<IClassKindEducationLogic>.Instance;
                case Reports.CATCH_SECTIONSET_GRADE:
                    return Container<IGradeSectionSettingsEducationLogic>.Instance;
                case Reports.CATCH_SECTIONSET_CLASS:
                    return Container<IClassSectionSettingsEducationLogic>.Instance;

                case Reports.CATCH_DISTRIBUTIONSET_GRADE:
                    return Container<IGradeDistributionEducationLogic>.Instance;
                case Reports.CATCH_DISTRIBUTIONSET_CLASS:
                    return Container<IClassesDistributionEducationLogic>.Instance;
                case Reports.CATCH_SCOREPOINTSET_GRADE:
                    return Container<IScorePointGradeEducationLogic>.Instance;
                case Reports.CATCH_SCOREPOINTSET_CLASS:
                    return Container<IScorePointClassesEducationLogic>.Instance;
            }
        }
        else
        {
            switch (keyWord)
            {
                case Reports.CATCH_KINDSET_CLASS:
                    return Container<IClassesKindSchoolLogic>.Instance;
                case Reports.CATCH_SECTIONSET_CLASS:
                    return Container<IClassesSectionSchoolLogic>.Instance;
                case Reports.CATCH_DISTRIBUTIONSET_CLASS:
                    return Container<IClassesDistributionSchoolLogic>.Instance;
            }
        }
        //throw new Exception("不支持的此接口");
        return null;
    }

    /// <summary>
    /// 定性设置
    /// </summary>
    protected const string TYPE_KINDSET = "KINDSET";
    /// <summary>
    /// 分数段设置
    /// </summary>
    protected const string TYPE_SECTIONSET = "SECTIONSET";
    /// <summary>
    /// 年级成绩分布
    /// </summary>
    protected const string TYPE_DISTRIBUTIONSET = "DISTRIBUTION";
    /// <summary>
    /// 统考分数线
    /// </summary>
    protected const string TYPE_SCOREPOINTSET = "SCOREPOINTSET";


    /// <summary>
    /// 定性设置缓存（年级）
    /// </summary>
    public const string CATCH_KINDSET_GRADE = "CATCH_KINDSET_GRADE";
    /// <summary>
    /// 定性设置缓存（班级）
    /// </summary>
    public const string CATCH_KINDSET_CLASS = "CATCH_KINDSET_CLASS";
    /// <summary>
    /// 分数段设置缓存（年级）
    /// </summary>
    public const string CATCH_SECTIONSET_GRADE = "CATCH_SECTIONSET_GRADE";
    /// <summary>
    /// 分数段设置缓存（班级）
    /// </summary>
    public const string CATCH_SECTIONSET_CLASS = "CATCH_SECTIONSET_CLASS";
    /// <summary>
    /// 年级排名分布缓存（年级）
    /// </summary>
    public const string CATCH_DISTRIBUTIONSET_GRADE = "CATCH_DISTRIBUTIONSET_GRADE";
    /// <summary>
    /// 年级排名分布缓存（班级）
    /// </summary>
    public const string CATCH_DISTRIBUTIONSET_CLASS = "CATCH_DISTRIBUTIONSET_CLASS";
    /// <summary>
    /// 统考分数线缓存（年级）
    /// </summary>
    public const string CATCH_SCOREPOINTSET_GRADE = "CATCH_SCOREPOINTSET_GRADE";
    /// <summary>
    /// 统考分数线缓存（班级）
    /// </summary>
    public const string CATCH_SCOREPOINTSET_CLASS = "CATCH_SCOREPOINTSET_CLASS";
}
